//
//  UILabel+CLHeight.m
//  CLBasicsDemo
//
//  Created by 小草毋正 on 2017/9/12.
//  Copyright © 2017年 zbw. All rights reserved.
//

#import "UILabel+CLHeight.h"



@implementation UILabel (CLHeight)

/** 返回自适应文字的高度(宽度为Label的宽度) */
- (CGFloat)heightOfSelfAdaption {
    return [self heightOfSelfAdaptionWithWidth:self.bounds.size.width];
}

/** 返回自适应文字的高度 */
- (CGFloat)heightOfSelfAdaptionWithWidth:(CGFloat)width {
    CGSize size = CGSizeMake(width, MAXFLOAT);
    CGFloat height = [self.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.font} context:nil].size.height;
    return height;
}



@end



